
(global-set-key (kbd "C-<left>") 'backward-word) 
(global-set-key (kbd "C-<right>") 'forward-word)



;;swiper
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "C-h f") 'counsel-describe-function)
(global-set-key (kbd "C-h v") 'counsel-describe-variable)
(global-set-key (kbd "C-h C-f") 'find-function)
(global-set-key (kbd "C-h C-v") 'find-variable)
(global-set-key (kbd "C-h C-k") 'find-function-on-key)

(add-to-list 'exec-path "C:/msys64/mingw64/bin")

(global-set-key (kbd "C-c p s") 'helm-do-ag-project-root)


;;配置快速启动配置文件
(defun open-my-init-file()
  (interactive)
  (find-file "~/.emacs.d/init.el"))
(global-set-key (kbd "<f2>") 'open-my-init-file)

(global-set-key (kbd "C-c p f") 'counsel-git);;查找项目下的文件

(global-set-key (kbd "C-M-\\") 'indent-region-or-buffer);;格式化代码
(global-set-key (kbd "s-/") 'hippie-expand);;hippie 自动补全快捷键

;;js2-refactor-mode config
(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c C-m");;js2-refactor 重构代码插件 快捷键

;;配置occur默认选中光标下的单词
(defun occur-dwim ()
  "Call `occur' with a sane default."
  (interactive)
  (push (if (region-active-p)
	    (buffer-substring-no-properties
	     (region-beginning)
	     (region-end))
	  (let ((sym (thing-at-point 'symbol)))
	    (when (stringp sym)
	      (regexp-quote sym))))
	regexp-history)
  (call-interactively 'occur))
(global-set-key (kbd "M-s o") 'occur-dwim);;转到字符串引用

(global-key-binding (kbd "M-s i") 'counsel-imenu);;转到函数引用

(global-set-key (kbd "C-=") 'er/expand-region);;增量选择块

(global-set-key (kbd "C-;") 'iedit-mode);;多行编辑

(global-set-key (kbd "C-c r") 'org-capture);;生成org片段

;;修改company 选取键
;;(with-eval-after-load 'company
;;  (define-key company-active-map (kbd "M-n") nil)
;;  (define-key company-active-map (kbd "M-p") nil)
;;  (define-key company-active-map (kbd "C-n") #'company-select-next)
;;  (define-key company-active-map (kbd "C-p") #'company-select-previous))

;;搜索工具 ag>pt>ack>grep


(setq ergoemacs-theme nil)
(setq ergoemacs-keyboard-layout "us")
(require 'ergoemacs-mode)
(ergoemacs-mode 1)


;;(Global-set-key (kbd "C-w") 'backward-kill-word);;回删一个单词
(provide 'init-keybindings)
